/**
 * 
 */
package export;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * This class provides an error log
 * 
 * @author Kevin Wagner
 * @version 1.0
 */
public class ErrorLog {
	
	/**
	 * @param e exception to log
	 */
	public static void Error(Exception e) {
		// Create file
		try {
			FileWriter fstream = new FileWriter("ErrorLog.log",true);
			BufferedWriter out = new BufferedWriter(fstream);
			SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd 'at' HH:mm:ss ");
			Date currentTime = new Date();
			out.append(formatter.format(currentTime)+" Error: "+e.getMessage());
			out.newLine();
			for(int i=0;i<e.getStackTrace().length;i++){
				out.append(e.getStackTrace()[i].toString());
				out.newLine();
			}
			out.newLine();
			out.flush();
			out.close();
		} catch (Exception ex) {
			// Nothing
		}
	}

}
